import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:kegelutils/page_home.dart';

class SplashPage extends StatefulWidget {
  const SplashPage({Key? key}) : super(key: key);

  @override
  State<SplashPage> createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> {
  //渐变效果设置
  late Gradient gradient;
  late Shader shader;

  @override
  void initState() {
    super.initState();
    gradient = const LinearGradient(
      begin: Alignment.centerLeft,
      end: Alignment.centerRight,
      colors: [
        Colors.red,
        Colors.purple,
      ],
    );
    shader = gradient.createShader(Rect.fromLTWH(
        0, 0, Get.mediaQuery.size.width, Get.mediaQuery.size.height));
    Future.delayed(const Duration(milliseconds: 2000), () {
      Get.off(const HomePage(), transition: Transition.downToUp);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.white,
      child: Center(
        child: FittedBox(
          child: Container(
            padding:
                const EdgeInsets.symmetric(horizontal: 30.0, vertical: 15.0),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(100.0),
              gradient: const LinearGradient(
                colors: [Colors.red, Colors.purple],
                begin: Alignment.centerLeft,
                end: Alignment.centerRight,
              ),
            ),
            child: const Text(
              "提肛运动助手",
              style: TextStyle(
                fontSize: 38,
                fontWeight: FontWeight.bold,
                color: Colors.white,
              ),
            ),
          ),
        ),
      ),
    );
  }
}
